package com.example.film.controller;

import com.example.film.entity.PublishInfo;
import com.example.film.service.PublishInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "发行信息管理接口")
@CrossOrigin
@RestController
@RequestMapping("publish/v1")
public class PublishInfoController {
    @Autowired
    private PublishInfoService publishInfoService;

    @ApiOperation("所有发行信息")
    @GetMapping("/info")
    public List<PublishInfo> getPublishInfo(){
        return publishInfoService.findPublishInfo();
    }

    @ApiOperation("分页查询所有发行信息")
    @GetMapping("/message")
    public List<PublishInfo> getPublishMessage(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
        return publishInfoService.findPublishMessage(pageNum, pageSize);
    }

    @ApiOperation("根据年份和月份查找发行信息")
    @GetMapping("/infoDate")
    public List<PublishInfo> getPublishInfoByDate(@RequestParam(defaultValue = "2023") Integer year,@RequestParam(defaultValue = "3") Integer month){
        return publishInfoService.findPublishInfoByDate(year, month);
    }
}
